<!DOCTYPE html>
<?php
require_once("funcs.php");
if (isset($_GET['hdn'])) {
  if (isset($_GET['page'])) {
    if ($_GET['page']=='next') $startIndex=$_GET['index']+25;
    if ($_GET['page']=='prev') $startIndex=$_GET['index']-25;
  } else  {
    $startIndex=1;
  }

  $index=$startIndex;
  $searchTerm=$_GET['hdn'];
  $maxResults=25;
   
  $searchString='http://gdata.youtube.com/feeds/api/videos?vq='.urlencode($searchTerm).'&search_sort=video_avg_rating&racy=include&max-results='.$maxResults.'&start-index='.$startIndex;
  $searchParam = "?search=".urlencode($searchString);
} else {
  $searchParam = "";
}
$bodyUrl = "content-search.php".$searchParam;
?><html>
<head>
  <title>iNMT</title>
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="apple-touch-icon" href="img/app-icon.png">
  <meta name="apple-touch-fullscreen" content="YES">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">

  <link rel="stylesheet" href="jqm/jquery.mobile-1.0a2.css" type="text/css">
  <link rel="stylesheet" href="inmt.css" type="text/css">
  <script src="jqm/jquery-1.4.4.js" type="text/javascript"></script>
  <script src="js/nmt.js" type="text/javascript"></script>
  <script type="text/javascript">
    nmt.setDoneURL('http://localhost:8883/start.cgi');
    nmt.setAddr('192.168.10.19');
  </script>
  
  <script type="text/javascript">
  $(document).ready(function() {
	  $(".pending").toggleClass("pending");
  });
  </script>
  <script src="jqm/jquery.mobile-1.0a2.min.js" type="text/javascript"></script>
</head>

<body class="pending">
  <div data-role="page">
    <div data-role="header">
      <h1>iNMT YouTube</h1>
    </div>
    
    <div data-role="content" id="search-box">
      <form action="index.php" method="get" id="frm" name="frm">
        <input type="search" id="search" name="hdn" value="">
      </form>
    </div>
    <div data-role="content" id="search-results">
<?php
  if (isset($searchString)) {
    echoVideoList($searchString);
  }
?>
    </div>
  </div>
</body>
</html>
